#include <boost/test/unit_test.hpp>

#include "time_24.h"

using namespace aviation;
using namespace std;

BOOST_AUTO_TEST_CASE(TestTimeDefaultConstructor)
{
	// Constructs an object with an appropriate string 
	Time time1;
	BOOST_REQUIRE(time1.AsString()== "0000");
}

BOOST_AUTO_TEST_CASE(TestTimeStringConstructor)
{
	// A time with good input
	Time time1(string("0915"));
	// Check correct output
	BOOST_REQUIRE(time1.AsString() == "0915");

	//Test the following bad inputs.
	BOOST_CHECK_THROW(Time(string("915")), exception);
	BOOST_CHECK_THROW(Time(string("09156")), exception);
	BOOST_CHECK_THROW(Time(string("")), exception);
	// Test invalid hour (digit 1)
	BOOST_CHECK_THROW(Time(string("3015")), exception);
	// Test invalid hour (digit 2)
	BOOST_CHECK_THROW(Time(string("2515")), exception);
	// Test invalid minute (digit 3)
	BOOST_CHECK_THROW(Time(string("0970")), exception);
	// Test invalid character
	BOOST_CHECK_THROW(Time(string("m915")), exception);
}

BOOST_AUTO_TEST_CASE(TestTimeCopyConstructor)
{
	// Copies the time from another.
	Time time1("0930");
	Time time2(time1);
	BOOST_REQUIRE(time1.AsString() == time2.AsString());

}

BOOST_AUTO_TEST_CASE(TestTimeAssignmentOperator)
{
	// Assignment operator, copies from 'other'
	Time time1("1225");
	Time time2;
	time2 = time1;
	BOOST_REQUIRE(time1.AsString() == time2.AsString());
}

BOOST_AUTO_TEST_CASE(TestTimeComparisonEqualOperator)
{
	//Returns true if they are the same, or false if they arent
	Time time1(string("1133"));
	Time time2(string("1133"));

	BOOST_REQUIRE(time1 == time2);


}

BOOST_AUTO_TEST_CASE(TestTimeComparisonNotEqualoperator)
{
	//Returns true if they are not the same, or false if they are
	Time time1(string("1508"));
	Time time2(string("1707"));
	BOOST_REQUIRE(time1!=time2);

}

BOOST_AUTO_TEST_CASE(TestTimeComparisonLessthanoperator)
{
	//Returns true if it is less than other, or false if it is greater than
	Time time1(string("0307"));
	Time time2(string("1222"));
	
	BOOST_REQUIRE(time1 < time2);
}

BOOST_AUTO_TEST_CASE(TestGetMinutes)
{
	//return the minutes
    Time time1(string("0523"));

	BOOST_REQUIRE(time1.GetMinutes() == 23);

}

BOOST_AUTO_TEST_CASE(TestGetHours)
{
	//return the hours
    Time time1(string("0523"));

	BOOST_REQUIRE(time1.GetHours() == 05);

}

BOOST_AUTO_TEST_CASE(TestTimeAsString)
{
	//return the time AsString as a string
    Time time1(string("1122"));

	BOOST_REQUIRE(time1.AsString() == "1122");

}